package com.yanqu.road.server.cmd.union.cross.huaben;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.union.cross.UnionHuaBenProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.union.huaben.CrossUnionHuaBenMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_CROSS_UNION_HUA_BEN_OPEN, desc = "开启话本")
public class CrossUnionHuaBenOpenCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        UnionHuaBenProto.UnionHuaBenOpenReqMsg reqMsg = UnionHuaBenProto.UnionHuaBenOpenReqMsg.parseFrom(packet.getBytes());

        ret = CrossUnionHuaBenMgr.openHuaBen(serverId, packet.getPlayerId(), reqMsg.getDegree());

        if(ret != 0){

            MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_CROSS_UNION_HUA_BEN_OPEN, UnionHuaBenProto.UnionHuaBenOpenRespMsg.newBuilder().setRet(ret)));

        }
    }

    @Override
    public void sendData() {

    }
}
